package it.fuesi.synoutils.services.tasks.download;

import android.content.Context;
import android.widget.Toast;

import it.fuesi.synoutils.model.base.VoidDataObject;
import it.fuesi.synoutils.model.base.VoidResponse;
import it.fuesi.synoutils.model.download.DownloadStationClientParameters;
import it.fuesi.synoutils.services.client.DownloadStationClient;
import it.fuesi.synoutils.services.client.ServiceClientFactory;
import it.fuesi.synoutils.services.tasks.base.BaseTask;

/**
 * Created by pascotto on 17/10/14.
 */
public class CreateEmuleDownloadTask extends BaseTask<VoidResponse, VoidDataObject, DownloadStationClientParameters> {

    private static final String TAG = CreateEmuleDownloadTask.class.getName();

    public CreateEmuleDownloadTask(Context context){
        super(context);
    }


    @Override
    protected String getCacheKey() {
        return null;
    }

    @Override
    public VoidResponse run(DownloadStationClientParameters params)  throws Exception{

            publishProgress("Adding emule download task");
            DownloadStationClient client = ServiceClientFactory.getClient(DownloadStationClient.class);

            return client.createEmuleTask("download", params.getFileID());

    }

    @Override
    public void onComplete(VoidResponse returnObject) {
        super.onComplete(returnObject);

        if(returnObject.isSuccess()){
            Toast.makeText(getContext(), "Added to download queue", Toast.LENGTH_LONG);
        }


    }
}
